import request from '@/utils/request'
import { isNotEmpty } from '@/utils'
import { getItem } from '@/utils/auth'

export function fetchSiteList(data) {
  return request({
    url: '/cloud-system/getSiteList',
    method: 'post',
    data
  })
}

export function fetchSiteOne(data) {
  return request({
    url: '/cloud-system/getOneSiteDetail',
    method: 'post',
    data
  })
}

export function createSite(data) {
  return request({
    url: '/cloud-system/createOneSite',
    method: 'post',
    data
  })
}
export function updateSite(data) {
  return request({
    url: '/cloud-system/updateOneSite',
    method: 'post',
    data
  })
}

export function deleteSite(data) {
  return request({
    url: '/cloud-system/deleteOneSite',
    method: 'post',
    data
  })
}
export function batchDeleteSite(data) {
  return request({
    url: '/cloud-system/batchDeleteSite',
    method: 'post',
    data
  })
}

export function lockSite(data) {
  return request({
    url: '/cloud-system/lockOneSite',
    method: 'post',
    data
  })
}

export function unlockSite(data) {
  return request({
    url: '/cloud-system/unlockOneSite',
    method: 'post',
    data
  })
}

export function batchLockSite(data) {
  return request({
    url: '/cloud-system/batchLockSite',
    method: 'post',
    data
  })
}

export function batchUnLockSite(data) {
  return request({
    url: '/cloud-system/batchUnLockSite',
    method: 'post',
    data
  })
}

export function login(data) {
  return request({
    url: '/cloud-system/userLogin',
    method: 'post',
    data
  })
}

export function logout(data) {
  return request({
    url: '/cloud-system/userLogout',
    method: 'post',
    data
  })
}

export function createUser(data) {
  return request({
    url: '/cloud-system/createOneUser',
    method: 'post',
    data
  })
}

export function updateUser(data) {
  return request({
    url: '/cloud-system/updateOneUser',
    method: 'post',
    data
  })
}

export function deleteUser(data) {
  return request({
    url: '/cloud-system/deleteOneUser',
    method: 'post',
    data
  })
}

export function getUserList(parameter) {
  const data = JSON.parse(getItem('baseParam'))
  if (isNotEmpty(parameter)) {
    data.parameterArray += (',' + parameter)
  }
  return request({
    url: '/cloud-system/getUserList',
    method: 'post',
    data: data
  })
}

